<template>
	<view>
		<button @click="onSetTimeCall()">单词定时器setTimeout</button>
		<button @click="onSetTimeCallxy(userName,password)">带参数setTimeout</button>
		<button @click="onTimeoutClear(userName,password)">取消定时器</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				userName:'cyz',
				password:'666',
				timeoutID:null,
				count:0,
				
			}
		},
		methods: {
			onSetTimeCall(){
				console.log("onSetTimeCall-->");
				this timeoutID setTimeout(()=>{
					console.log("我延时2秒才会打印");
				},3000)
			},
			onSetTimeCallxy(name,pwd){
				console.log("onSetTimeCallxy--> name:"+name+"pwd"+pwd)
				setTimeout((x,y)=>{
					console.log("我可以传参数")
				},2000,name,pwd)
			},
			onTimeoutClear(){
				console.log("onTimeoutClear------>定时器被我取消了:"+ this.timeoutID)
				clearTimeout(this.timeoutID)
			},
			onInteral(){
				setInterval(()=>{
					this.count++;
					console.log("周期打印 count:",this,count);
				}1000)
			},
			onClearInter()
		}
	}
</script>

<style>

</style>
